package com.wei.czz.framework.common.service;

import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.function.Supplier;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-07-08 17:36:06
 * className: TransactionService 事务执行服务类
 * version: 1.0
 * description:
 */
@Service
@AllArgsConstructor
public class TransactionService {

    private static final Logger log = LoggerFactory.getLogger(TransactionService.class);

    @Transactional
    public void execute(Runnable runnable) {
        runnable.run();
    }

    @Transactional
    public <T> T execute(Supplier<T> supplier) {
        return supplier.get();
    }

}
